<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="客户姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入客户姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="证件号码" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入证件号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管户机构" prop="orgId">
        <el-select v-model="queryParams.orgId" @change="orgIdBlur(queryParams.orgId)" clearable placeholder="请选择"><el-option v-for="item in orgList" :key="item.value" :label="item.orgName" :value="item.orgId"></el-option></el-select>
      </el-form-item>
      <el-form-item label="管户经理" prop="userId">
        <el-select v-model="queryParams.userId" clearable placeholder="请选择"><el-option v-for="item in mangerList" :key="item.value" :label="item.nickName" :value="item.userName"></el-option></el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5"><el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['buss:sqzxt:add']">新增</el-button></el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['buss:sqzxt:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5"><el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['buss:sqzxt:export']">导出</el-button></el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="bpsqList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="户主" align="center" prop="hzxm"  />
      <el-table-column label="户籍编号" width="180" align="center" prop="hjbh"  />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="证件号码" width="180" align="center" prop="idCard" />
      <el-table-column label="联系电话" width="180" align="center" prop="phone" />
      <el-table-column label="性别" align="center" prop="sex" :formatter="sexFormat" />
      <el-table-column label="与户主关系" width="180" align="center" prop="yhzgx" :formatter="yhzgxFormat"/>
      <el-table-column label="所属社区" align="center" width="180" prop="sssq"  />
      <!-- <el-table-column label="长期居住" align="center" width="100" prop="longLive"  /> -->
      <el-table-column label="地址" width="180" align="center" prop="address" :show-overflow-tooltip="true" />
      <el-table-column label="家庭人口" align="center" prop="labour" />
      <!-- <el-table-column label="社区活动参与次数" width="180" align="center" prop="joinAcive"/> -->
      <el-table-column label="客户类型" align="center" prop="customerType" :formatter="custmerTypeFormat" />
      <el-table-column label="客户星级" align="center" prop="level" :formatter="khxjFormat" />
      <!-- <el-table-column label="贫困户" align="center" prop="pkh" :formatter="pkhTypeFormat"/> -->
      <!-- <el-table-column label="黑名单" align="center" prop="black" :formatter="blackTypeFormat"  /> -->
      <el-table-column label="管户机构" align="center" width="180" prop="orgId" :formatter="orgIdFormat" />
      <el-table-column label="管户经理" align="center" prop="userId" :formatter="userIdFormat" />
      <el-table-column label="操作" fixed="right" width="220" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <router-link :to="{ path: '/sq/sqdetail/', query: { sqBG: scope.row } }" class="link-type"><span>客户视图  </span></router-link>
          <router-link :to="{ path: '/sq/sqbg/', query: { sqBG: scope.row } }" class="link-type"><span>  变更记录</span></router-link>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改网格村居-包片居民报表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="dataWgWgsqSq" :model="dataWgWgsqSq" :rules="rules" label-width="120px">
        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamesk">
              <el-collapse-item title="存量客户" name="1">
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="姓名" prop="name"><el-input v-model="dataWgWgsqSq.name" placeholder="请输入姓名" clearable :style="{ width: '100%' }"></el-input></el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="身份证号" prop="idCard">
                          <el-input v-model="dataWgWgsqSq.idCard" placeholder="请输入身份证" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="户主姓名" prop="hzxm">
                          <el-input v-model="dataWgWgsqSq.hzxm" placeholder="请输入户主姓名" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="户籍编号" prop="hjbh">
                          <el-input v-model="dataWgWgsqSq.hjbh" placeholder="请输入户籍编号" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="年龄" prop="age"><el-input v-model="dataWgWgsqSq.age" placeholder="请输入年龄" clearable :style="{ width: '100%' }"></el-input></el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="手机号" prop="phone">
                          <el-input v-model="dataWgWgsqSq.phone" placeholder="请输入手机号" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>

                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="管户机构" prop="orgId">
                        <el-select v-model="orgvalue" @change="orgIdBlur(orgvalue)" clearable placeholder="请选择"><el-option v-for="item in orgList" :key="item.value" :label="item.orgName" :value="item.orgId"></el-option></el-select>
                      </el-input></el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="管户经理" prop="managerId">
                        <el-select v-model="managervalue" clearable placeholder="请选择"><el-option v-for="item in mangerList" :key="item.value" :label="item.nickName" :value="item.userId"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="客户类型" prop="khlx">
                          <el-select v-model="khlxvalue" placeholder="请选择">
                              <el-option
                                v-for="item in khlx"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                              </el-option>
                            </el-select>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                 <div>
                   <el-col :span="12">
                     <div style="margin: 1.5625rem;font-size: 14px;">
                       <el-form-item label="客群标签" prop="groupLabel">
                         <el-select v-model="qtbqvalue" @change="selectWorkName" multiple placeholder="请选择">
                             <el-option
                               v-for="item in groupList"
                               :key="item.value"
                               :label="item.groupName"
                               :value="`${item.groupName}|${item.groupCode}`">
                             </el-option>
                           </el-select>
                       </el-form-item>
                     </div>
                   </el-col>
                 </div>


              </el-collapse-item>

            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamesss">
              <el-collapse-item title="网格社区" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="家庭人口" prop="labour">
                        <el-input v-model="dataWgWgsqSq.labour" placeholder="请输入家庭人口" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="地址" prop="jzAddress">
                        <el-input v-model="dataWgWgsqSq.jzAddress" placeholder="请输入地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="活动次数" prop="joinAcive">
                        <el-input v-model="dataWgWgsqSq.joinAcive" placeholder="请输入活动参与次数" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属社区" prop="sssjsq">
                        <el-select v-model="dataWgWgsqSq.sssjsq" @change="sssqBlur(dataWgWgsqSq.sssjsq)" clearable placeholder="请选择"><el-option v-for="item in sssjsqList" :key="item.value" :label="item.sssjsq" :value="item.sssjsq"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="长期居住" prop="longLive">
                        <el-select v-model="cqjzvalue" clearable placeholder="请选择"><el-option v-for="item in cqjz" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属小区" prop="sssq">
                        <el-select v-model="dataWgWgsqSq.sssq" clearable placeholder="请选择"><el-option v-for="item in xsqList" :key="item.value" :label="item.sssq" :value="item.sssq"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>

                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="与户主关系" prop="yhzgx">
                        <el-select v-model="yhzgxvalue" clearable placeholder="请选择"><el-option v-for="item in yhzgx" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>

                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="备注" prop="remark">
                        <el-input v-model="dataWgWgsqSq.remark" placeholder="请输入备注" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNames" >
              <el-collapse-item title="网格商户" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="商户门头" prop="shmt">
                        <el-input v-model="dataWgWgsqSq.shmt" placeholder="请输入商户门头" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="注册名称" prop="shzcmc">
                        <el-input v-model="dataWgWgsqSq.shzcmc" placeholder="请输入注册名称" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="法定代表人" prop="fddbr">
                        <el-input v-model="dataWgWgsqSq.fddbr" placeholder="请输入法定代表人" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="代表人证件" prop="fddbrzjhm">
                        <el-input v-model="dataWgWgsqSq.fddbrzjhm" placeholder="请输入代表人证件" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="实际经营人" prop="sjjyr">
                        <el-input v-model="dataWgWgsqSq.sjjyr" placeholder="请输入实际经营人" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营人证件" prop="sjjyrzjhm">
                        <el-input v-model="dataWgWgsqSq.sjjyrzjhm" placeholder="请输入经营人证件" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营地址" prop="jydz">
                        <el-input v-model="dataWgWgsqSq.jydz" placeholder="请输入经营地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属行业" prop="sshy">
                        <el-select v-model="dataWgWgsqSq.sshy" clearable placeholder="请选择"><el-option v-for="item in sshy" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营状况" prop="jyzk">
                        <el-select v-model="dataWgWgsqSq.jyzk" clearable placeholder="请选择"><el-option v-for="item in jyzk" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">

                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamecj" >
              <el-collapse-item title="网格村居" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="镇" prop="town">
                        <el-select v-model="dataWgWgsqSq.town" @change="townBlur(dataWgWgsqSq.town)" clearable placeholder="请选择"><el-option v-for="item in townList" :key="item.value" :label="item.town" :value="item.town"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="村组" prop="village">
                        <el-select v-model="dataWgWgsqSq.village" clearable placeholder="请选择"><el-option v-for="item in vellageList" :key="item.value" :label="item.village" :value="item.village"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="居住地址" prop="address">
                        <el-input v-model="dataWgWgsqSq.address" placeholder="请输入居住地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="务工地点" prop="workAddress">
                        <el-input v-model="dataWgWgsqSq.workAddress" placeholder="请输入务工地点" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="性别" prop="sex">
                        <el-select v-model="xbvalue" clearable placeholder="请选择"><el-option v-for="item in xb" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="与户主关系" prop="yhzgx1">
                        <el-select v-model="cjyhzgxvalue" clearable placeholder="请选择"><el-option v-for="item in cjyhzgx" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="健康状况" prop="health">
                        <el-select v-model="healthvalue" clearable placeholder="请选择"><el-option v-for="item in cjhealth" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="房产" prop="houser">
                        <el-select v-model="houservalue" clearable placeholder="请选择"><el-option v-for="item in houser" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="车产" prop="car">
                        <el-select v-model="carvalue" clearable placeholder="请选择"><el-option v-for="item in car" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="不良嗜好" prop="badHabits">
                        <el-select v-model="badHabitsvalue" clearable placeholder="请选择"><el-option v-for="item in badHabits" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="title" :visible.sync="openUpdata" width="1000px" append-to-body>
      <el-form ref="dataWgWgsqSq" :model="dataWgWgsqSqUpdate" :rules="rules" label-width="120px">
        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamesk">
              <el-collapse-item title="存量客户" name="1">
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="姓名" prop="name"><el-input v-model="dataWgWgsqSqUpdate.name" placeholder="请输入姓名" clearable :style="{ width: '100%' }"></el-input></el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="身份证号" prop="idCard">
                          <el-input v-model="dataWgWgsqSqUpdate.idCard" placeholder="请输入身份证" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="户主姓名" prop="hzxm">
                          <el-input v-model="dataWgWgsqSqUpdate.hzxm" placeholder="请输入户主姓名" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="户籍编号" prop="hjbh">
                          <el-input v-model="dataWgWgsqSqUpdate.hjbh" placeholder="请输入户籍编号" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="年龄" prop="age"><el-input v-model="dataWgWgsqSqUpdate.age" placeholder="请输入年龄" clearable :style="{ width: '100%' }"></el-input></el-form-item>
                      </div>
                    </el-col>
                </div>
                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="手机号" prop="phone">
                          <el-input v-model="dataWgWgsqSqUpdate.phone" placeholder="请输入手机号" clearable :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                      </div>
                    </el-col>

                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="管户机构" prop="orgId">
                        <el-select v-model="orgvalue" @change="orgIdBlur(orgvalue)" clearable placeholder="请选择"><el-option v-for="item in orgList" :key="item.value" :label="item.orgName" :value="item.orgId"></el-option></el-select>
                      </el-input></el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="管户经理" prop="managerId">
                        <el-select v-model="managervalue" clearable placeholder="请选择"><el-option v-for="item in mangerList" :key="item.value" :label="item.nickName" :value="item.userId"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>

                <div>
                    <el-col :span="12">
                      <div style="margin: 1.5625rem;font-size: 14px;">
                        <el-form-item label="客户类型" prop="khlx">
                          <el-select v-model="khlxvalue" placeholder="请选择">
                              <el-option
                                v-for="item in khlx"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                              </el-option>
                            </el-select>
                        </el-form-item>
                      </div>
                    </el-col>
                </div>
                 <div>
                   <el-col :span="12">
                     <div style="margin: 1.5625rem;font-size: 14px;">
                       <el-form-item label="客群标签" prop="groupLabel">
                         <el-select v-model="qtbqvalue" @change="selectWorkName" multiple placeholder="请选择">
                             <el-option
                               v-for="item in groupList"
                               :key="item.value"
                               :label="item.groupName"
                               :value="`${item.groupName}|${item.groupCode}`">
                             </el-option>
                           </el-select>
                       </el-form-item>
                     </div>
                   </el-col>
                 </div>


              </el-collapse-item>

            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamesss">
              <el-collapse-item title="网格社区" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="家庭人口" prop="labour">
                        <el-input v-model="dataWgWgsqSqUpdate.labour" placeholder="请输入家庭人口" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="地址" prop="jzAddress">
                        <el-input v-model="dataWgWgsqSqUpdate.jzAddress" placeholder="请输入地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="活动次数" prop="joinAcive">
                        <el-input v-model="dataWgWgsqSqUpdate.joinAcive" placeholder="请输入活动参与次数" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属社区" prop="sssjsq">
                        <el-select v-model="dataWgWgsqSqUpdate.sssjsq" @change="sssqBlur(dataWgWgsqSqUpdate.sssjsq)" clearable placeholder="请选择"><el-option v-for="item in sssjsqList" :key="item.value" :label="item.sssjsq" :value="item.sssjsq"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="长期居住" prop="longLive">
                        <el-select v-model="cqjzvalue" clearable placeholder="请选择"><el-option v-for="item in cqjz" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属小区" prop="sssq">
                        <el-select v-model="dataWgWgsqSqUpdate.sssq" clearable placeholder="请选择"><el-option v-for="item in xsqList" :key="item.value" :label="item.sssq" :value="item.sssq"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>

                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="与户主关系" prop="yhzgx">
                        <el-select v-model="yhzgxvalue" clearable placeholder="请选择"><el-option v-for="item in yhzgx" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>

                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="备注" prop="remark">
                        <el-input v-model="dataWgWgsqSqUpdate.remark" placeholder="请输入备注" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNames" >
              <el-collapse-item title="网格商户" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="商户门头" prop="shmt">
                        <el-input v-model="dataWgWgsqSqUpdate.shmt" placeholder="请输入商户门头" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="注册名称" prop="shzcmc">
                        <el-input v-model="dataWgWgsqSqUpdate.shzcmc" placeholder="请输入注册名称" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="法定代表人" prop="fddbr">
                        <el-input v-model="dataWgWgsqSqUpdate.fddbr" placeholder="请输入法定代表人" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="代表人证件" prop="fddbrzjhm">
                        <el-input v-model="dataWgWgsqSqUpdate.fddbrzjhm" placeholder="请输入代表人证件" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="实际经营人" prop="sjjyr">
                        <el-input v-model="dataWgWgsqSqUpdate.sjjyr" placeholder="请输入实际经营人" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营人证件" prop="sjjyrzjhm">
                        <el-input v-model="dataWgWgsqSqUpdate.sjjyrzjhm" placeholder="请输入经营人证件" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营地址" prop="jydz">
                        <el-input v-model="dataWgWgsqSqUpdate.jydz" placeholder="请输入经营地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="所属行业" prop="sshy">
                        <el-select v-model="dataWgWgsqSqUpdate.sshy" clearable placeholder="请选择"><el-option v-for="item in sshy" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="经营状况" prop="jyzk">
                        <el-select v-model="dataWgWgsqSqUpdate.jyzk" clearable placeholder="请选择"><el-option v-for="item in jyzk" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">

                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>

        <el-col :span="24">
          <div style="margin: 1.5625rem;font-size: 14px;">
            <el-collapse v-model="activeNamecj" >
              <el-collapse-item title="网格村居" name="1">
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="镇" prop="town">
                        <el-select v-model="dataWgWgsqSqUpdate.town" @change="townBlur(dataWgWgsqSqUpdate.town)" clearable placeholder="请选择"><el-option v-for="item in townList" :key="item.value" :label="item.town" :value="item.town"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="村组" prop="village">
                        <el-select v-model="dataWgWgsqSqUpdate.village" clearable placeholder="请选择"><el-option v-for="item in vellageList" :key="item.value" :label="item.village" :value="item.village"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="居住地址" prop="address">
                        <el-input v-model="dataWgWgsqSqUpdate.address" placeholder="请输入居住地址" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="务工地点" prop="workAddress">
                        <el-input v-model="dataWgWgsqSqUpdate.workAddress" placeholder="请输入务工地点" clearable :style="{ width: '100%' }"></el-input>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="性别" prop="sex">
                        <el-select v-model="xbvalue" clearable placeholder="请选择"><el-option v-for="item in xb" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="与户主关系" prop="yhzgx1">
                        <el-select v-model="cjyhzgxvalue" clearable placeholder="请选择"><el-option v-for="item in cjyhzgx" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="健康状况" prop="health">
                        <el-select v-model="healthvalue" clearable placeholder="请选择"><el-option v-for="item in cjhealth" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="房产" prop="houser">
                        <el-select v-model="houservalue" clearable placeholder="请选择"><el-option v-for="item in houser" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="车产" prop="car">
                        <el-select v-model="carvalue" clearable placeholder="请选择"><el-option v-for="item in car" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
                <div>
                  <el-col :span="12">
                    <div style="margin: 1.5625rem;font-size: 14px;">
                      <el-form-item label="不良嗜好" prop="badHabits">
                        <el-select v-model="badHabitsvalue" clearable placeholder="请选择"><el-option v-for="item in badHabits" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select>
                      </el-form-item>
                    </div>
                  </el-col>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormUpdate">确 定</el-button>
        <el-button @click="cancelUpData">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { selectSssqList, orglist, queryManager, listGroup } from '@/api/buss/sqzxt';
import { listBpsq } from "@/api/buss/bpsq";
import { selectTownOrVillage} from "@/api/buss/gridCJ";
import { addCustomer, updateCustomer, queryCustomerInfo} from '@/api/buss/customer';
import { jquery } from '@/utils/jquery-1.8.3.min';

export default {
  name: "Bpjm",
  components: {
  },
  data() {
    return {
     // 遮罩层1
     loading: true,
     // 选中数组
     ids: [],
     // 非单个禁用
     single: true,
     // 非多个禁用
     multiple: true,
     // 显示搜索条件
     showSearch: true,
     // 总条数
     total: 0,
     // 网格社区按社区维度统计表格数据
     sqzxtList: [],
     activeNames: ['1'],
     activeNamesss: ['1'],
     activeNamesk: ['1'],
     activeNamecj: ['1'],
     sexOptions: [],
     dataWgWgsqSqUpdate: {
       name: '',
       idCard: '',
       hzxm: '',
       hjbh: '',
       age: '',
       phone: '',
       labour: '',
       address: '',
       joinAcive: '',
       sssq: '',
       longLive: '',
       yhzgx: '',
       orgId: '',
       managerId: '',
       remark: '',
       sssjsq: '',
       khlx: '',
       groupLabel: '',
       sshy: '',
       jyzk: '',
       jydz: '',
       sjjyrzjhm: '',
       sjjyr: '',
       fddbrzjhm: '',
       fddbr: '',
       shzcmc: '',
       shmt: '',
       town: '',
       village: '',
       jzAddress: '',
       workAddress: '',
       sex: '',
       yhzgx1: '',
       health: '',
       car: '',
       hourse: '',
       badHabits: ''
     },
     dataWgWgsqSq: {
       name: '',
       idCard: '',
       hzxm: '',
       hjbh: '',
       age: '',
       phone: '',
       labour: '',
       address: '',
       joinAcive: '',
       sssq: '',
       longLive: '',
       yhzgx: '',
       orgId: '',
       managerId: '',
       remark: '',
       sssjsq: '',
       khlx: '',
       groupLabel: '',
       sshy: '',
       jyzk: '',
       jydz: '',
       sjjyrzjhm: '',
       sjjyr: '',
       fddbrzjhm: '',
       fddbr: '',
       shzcmc: '',
       shmt: '',
       town: '',
       village: '',
       jzAddress: '',
       workAddress: '',
       sex: '',
       yhzgx1: '',
       health: '',
       car: '',
       hourse: '',
       badHabits: ''
     },
     // 弹出层标题
     title: '',
     // 是否显示弹出层
     open: false,
     cjyhzgx: [
       {
         value: '1',
         label: '户主'
       },
       {
         value: '2',
         label: '配偶'
       },
       {
         value: '3',
         label: '父母'
       },
       {
         value: '4',
         label: '子女'
       },
       {
         value: '5',
         label: '其他'
       }
     ],
     cjyhzgxvalue: '',
     cjhealth: [
       {
         value: '0',
         label: '健康'
       },
       {
         value: '1',
         label: '一般'
       },
       {
         value: '2',
         label: '重大疾病'
       }
     ],
     healthvalue: '',
     car: [
       {
         value: '0',
         label: '私家车'
       },
       {
         value: '1',
         label: '大型农机'
       },
       {
         value: '2',
         label: '无'
       }
     ],
     carvalue: '',
     houser: [
       {
         value: '0',
         label: '农村平方'
       },
       {
         value: '1',
         label: '农村楼房'
       },
       {
         value: '2',
         label: '县级以上商品房'
       }
     ],
     houservalue: '',
     badHabits: [
       {
         value: '0',
         label: '有'
       },
       {
         value: '1',
         label: '无'
       }
     ],
     badHabitsvalue: '',
     xb: [
       {
         value: '0',
         label: '男'
       },
       {
         value: '1',
         label: '女'
       }
     ],
     xbvalue: '',
     cqjz: [
       {
         value: '0',
         label: '是'
       },
       {
         value: '1',
         label: '否'
       }
     ],
     cqjzvalue: '',
     khlx: [
       {
         value: '0',
         label: '普通客户'
       },
       {
         value: '1',
         label: '潜在客户'
       },
       {
         value: '2',
         label: '重点客户'
       }
     ],
     khlxvalue: '',
     jyzk: [
       {
         value: '0',
         label: '关闭'
       },
       {
         value: '1',
         label: '正常'
       },
       {
         value: '2',
         label: '其他'
       }
     ],
     jyzkvalue: '',
     yhzgx: [
       {
         value: '1',
         label: '户主'
       },
       {
         value: '2',
         label: '配偶'
       },
       {
         value: '3',
         label: '父母'
       },
       {
         value: '4',
         label: '子女'
       },
       {
         value: '5',
         label: '其他'
       }
     ],
     yhzgxvalue: '',
     sshy: [
       {
         value: '1',
         label: '餐饮'
       },
       {
         value: '2',
         label: '住宿'
       },
       {
         value: '3',
         label: '商超零售'
       },
       {
         value: '4',
         label: '水产批发'
       },
       {
         value: '5',
         label: '汽车服务'
       },
       {
         value: '6',
         label: '居民服务'
       },
       {
         value: '7',
         label: '其他'
       }
     ],
     sshyvalue: '',
     orgvalue: '',
     // 查询参数
     queryParams: {
       pageNum: 1,
       pageSize: 10,
       id: null,
       sssq: null,
       hs: null,
       ckhs: null,
       ckye: null,
       dkhs: null,
       dkye: null,
       etchs: null,
       xykhs: null,
       sjwxhs: null,
       sbkhs: null,
       yxdkrs: null,
       rs: null,
       dzyhgs: null,
       productFamilyHs: null,
       productCoverage: null,
       vaildFamilyHs: null,
       familyCoverage: null,
       orgId: '',
       managerId: null,
       userId: '',
       rzlcoount: null,
       familyfgm: null,
       rzl: null,
       xzjmzb: null,
       gtgshzb: null,
       gzryzb: null,
       sjrq: null,
       amountYsh: null,
       ifysx: null,
       qyZjhm: null,
       sxje: null,
       familyQyCoverage: null,
       sfyxdkAll: null
     },
     // 表单参数
     form: {

     },
     // 表单校验
     rules: {
       name: [
              { required: true, message: '姓名不能为空', trigger: 'blur' },
                { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
              ],
       // sshy: [
       //    {required: true, message: "所属行业不能为空" ,trigger: 'blur'},
       // ],
       // shmt: [
       //    {required: true, message: "商户门头不能为空" ,trigger: 'blur'},
       // ],
       // jyzk: [
       //    {required: true, message: "经营状况不能为空" ,trigger: 'blur'},
       // ],
       // sssjsq: [
       //    {required: true, message: "所属小区不能为空" ,trigger: 'blur'},
       // ],
       // sssq: [
       //    {required: true, message: "所属社区不能为空" ,trigger: 'blur'},
       // ],
     },
     sssq: '',
     orgList: [],
     sqKhxx: [],
     sqtype: {
       type: '1'
     },
     xqtype: {
       type: '2',
       sssjsq: ''
     },
     // 机构ID字典
     orgIdOptions: [],
     sssjsqList: [],
     sssjsqvalue: '',
     xsqList: [],
     xqvalue: '',
     manger: {
       orgId: ''
     },
     mangerList: [],
     managervalue: '',
     qtbqvalue: '',
     groupList: [],
     bpsqList: [],
     ifUpAndAdd: false,
     upDateId: '',
     queryInfo: {},
     townList: [],
     vellageList: [],
     zhen: {
       cjType: '3'
       },
     cunzu: {
       cjType: '1',
       town: ''
     },
     khxjOptions: [],
     custmertypeOptions: [],
     busstypeOptions: [],
     wgcjyhzgxOptions: [],
     pkhbusstypeOptions: [],
     blacktypeOptions: [],
     openUpdata: false
    };
  },
  created() {
    this.getList();
    this.getDicts("sys_user_sex").then(response => {
      this.sexOptions = response.data;
    });
    this.getDicts("data_customer_level").then(response => {
      this.levelOptions = response.data;
    });
    this.getDicts("sys_org_id").then(response => {
      this.orgIdOptions = response.data;
    });
    this.getDicts("sys_user_id").then(response => {
      this.userIdOptions = response.data;
    });
    this.getDicts("sys_custmer_type").then(response => {
      this.custmertypeOptions = response.data;
    });
    this.getDicts("sys_buss_type").then(response => {
      this.busstypeOptions = response.data;
    });
    this.getDicts("sys_khxj").then(response => {
      this.khxjOptions = response.data;
    });
    this.getDicts("wgcj_yhzgx").then(response => {
      this.wgcjyhzgxOptions = response.data;
    });
  },
  methods: {
    /** 查询网格村居-包片居民报表列表 */
    getList() {
      this.loading = true;
      listBpsq(this.queryParams).then(response => {
        this.bpsqList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

      //客群标签
      listGroup().then(response => {
         this.groupList = response.rows;
      });
      //下拉社区
      selectSssqList(this.sqtype).then(response => {
        this.sssjsqList = response;
        //console.log(JSON.stringify(this.sssjsqList))
      });
      //下拉机构
      orglist().then(response => {
        this.orgList = response.rows;
      });
      //镇
      selectTownOrVillage(this.zhen).then(response => {
        this.townList = response.data;

      });
    },
    //客户视图
    handleDetailUpdate(row) {
      const tableId = row.idCard;
      this.$router.push('/buss/detailTable/' + tableId);
    },
    selectWorkName(id){
      var sp = JSON.stringify(this.qtbqvalue);
      let [lable,vaue] = sp.split('|')
        console.log(vaue)
        console.log("select中对应value值",JSON.stringify(this.qtbqvalue))
    },
    townBlur(townvalue) {
      this.cunzu.town = townvalue
      selectTownOrVillage(this.cunzu).then(response => {
        this.vellageList = response.data;
        //console.log(JSON.stringify(this.sssjsqList))
      });
    },
    //客户经理
    orgIdBlur(mg) {
      this.manger.orgId = mg;
      queryManager(this.manger).then(response => {
        this.mangerList = response.rows;
      });
    },
    sssqBlur(sssjsqvalue) {
      //下拉小区
      this.xqtype.sssjsq = sssjsqvalue
      selectSssqList(this.xqtype).then(response => {
        this.xsqList = response;
        //console.log(JSON.stringify(this.sssjsqList))
      });
      console.log(sssjsqvalue)
    },
    orgIdFormat(row, column) {
      return this.selectDictLabel(this.orgIdOptions, row.orgId);
    },
    userIdFormat(row, column) {
      return this.selectDictLabel(this.userIdOptions, row.userId);
    },
    // 与户主关系字典翻译
    yhzgxFormat(row, column) {
      return this.selectDictLabel(this.wgcjyhzgxOptions, row.yhzgx);
    },
    // 客户星级字典翻译
    khxjFormat(row, column) {
      return this.selectDictLabel(this.khxjOptions, row.level);
    },
    // 业务是否类型字典翻译
    pkhTypeFormat(row, column) {
      return this.selectDictLabel(this.pkhbusstypeOptions, row.pkh);
    },
    blackTypeFormat(row, column) {
      return this.selectDictLabel(this.blacktypeOptions, row.black);
    },
    // 客户类型字典翻译
    custmerTypeFormat(row, column) {
      return this.selectDictLabel(this.custmertypeOptions, row.customerType);
    },
    // 性别字典翻译
    sexFormat(row, column) {
      return this.selectDictLabel(this.sexOptions, row.sex);
    },
    // 村字典翻译
    villageFormat(row, column) {
      return this.selectDictLabel(this.villageOptions, row.village);
    },
    // 户数字典翻译
    hsFormat(row, column) {
      return this.selectDictLabel(this.hsOptions, row.hs);
    },
    // 总人数字典翻译
    zrsFormat(row, column) {
      return this.selectDictLabel(this.zrsOptions, row.zrs);
    },
    // 存款余额字典翻译
    ckyeFormat(row, column) {
      return this.selectDictLabel(this.ckyeOptions, row.ckye);
    },
    // 存款户数字典翻译
    ckhsFormat(row, column) {
      return this.selectDictLabel(this.ckhsOptions, row.ckhs);
    },
    // 人均存款金额字典翻译
    rjckjeFormat(row, column) {
      return this.selectDictLabel(this.rjckjeOptions, row.rjckje);
    },
    // 有效存款户数字典翻译
    yxckhsFormat(row, column) {
      return this.selectDictLabel(this.yxckhsOptions, row.yxckhs);
    },
    // 贷款余额字典翻译
    dkyeFormat(row, column) {
      return this.selectDictLabel(this.dkyeOptions, row.dkye);
    },
    // 贷款户数字典翻译
    dkhsFormat(row, column) {
      return this.selectDictLabel(this.dkhsOptions, row.dkhs);
    },
    // 人均贷款金额字典翻译
    rjdkjeFormat(row, column) {
      return this.selectDictLabel(this.rjdkjeOptions, row.rjdkje);
    },
    // 授信户数字典翻译
    sxqyhsFormat(row, column) {
      return this.selectDictLabel(this.sxqyhsOptions, row.sxqyhs);
    },
    // 授信签约率字典翻译
    sxqylFormat(row, column) {
      return this.selectDictLabel(this.sxqylOptions, row.sxqyl);
    },
    // 用信签约率字典翻译
    yxqylFormat(row, column) {
      return this.selectDictLabel(this.yxqylOptions, row.yxqyl);
    },
    // 电子银行个数字典翻译
    dzyhgsFormat(row, column) {
      return this.selectDictLabel(this.dzyhgsOptions, row.dzyhgs);
    },
    // 人均电子银行个数字典翻译
    rjdzyhgsFormat(row, column) {
      return this.selectDictLabel(this.rjdzyhgsOptions, row.rjdzyhgs);
    },
    // 活跃电子银行个数字典翻译
    hydzyhgsFormat(row, column) {
      return this.selectDictLabel(this.hydzyhgsOptions, row.hydzyhgs);
    },
    // 人均活跃电子银行个数字典翻译
    rjhydzyhgsFormat(row, column) {
      return this.selectDictLabel(this.rjhydzyhgsOptions, row.rjhydzyhgs);
    },
    // 有产品户数字典翻译
    productHsFormat(row, column) {
      return this.selectDictLabel(this.productHsOptions, row.productHs);
    },
    // 有有效产品户数字典翻译
    vaildHsFormat(row, column) {
      return this.selectDictLabel(this.vaildHsOptions, row.vaildHs);
    },
    // 产品覆盖面字典翻译
    productCoverageFormat(row, column) {
      return this.selectDictLabel(this.productCoverageOptions, row.productCoverage);
    },
    // 有效客户产品覆盖面字典翻译
    vaildCoverageFormat(row, column) {
      return this.selectDictLabel(this.vaildCoverageOptions, row.vaildCoverage);
    },
    // 18岁以下字典翻译
    agezFormat(row, column) {
      return this.selectDictLabel(this.agezOptions, row.agez);
    },
    // 大于等于18 小于25字典翻译
    ageoneFormat(row, column) {
      return this.selectDictLabel(this.ageoneOptions, row.ageone);
    },
    // 大于等于25 小于35字典翻译
    agetwoFormat(row, column) {
      return this.selectDictLabel(this.agetwoOptions, row.agetwo);
    },
    // 大于等于35小于55字典翻译
    agethreeFormat(row, column) {
      return this.selectDictLabel(this.agethreeOptions, row.agethree);
    },
    // 大于等于55 小于65字典翻译
    agefourFormat(row, column) {
      return this.selectDictLabel(this.agefourOptions, row.agefour);
    },
    // 大于等于65字典翻译
    agefiveFormat(row, column) {
      return this.selectDictLabel(this.agefiveOptions, row.agefive);
    },
    // 一星客户数字典翻译
    firstlevelFormat(row, column) {
      return this.selectDictLabel(this.firstlevelOptions, row.firstlevel);
    },
    // 二星客户数字典翻译
    seclevelFormat(row, column) {
      return this.selectDictLabel(this.seclevelOptions, row.seclevel);
    },
    // 三星客户数字典翻译
    thrlevelFormat(row, column) {
      return this.selectDictLabel(this.thrlevelOptions, row.thrlevel);
    },
    // 四星客户数字典翻译
    fourlevelFormat(row, column) {
      return this.selectDictLabel(this.fourlevelOptions, row.fourlevel);
    },
    // 五星客户数字典翻译
    fivelevelFormat(row, column) {
      return this.selectDictLabel(this.fivelevelOptions, row.fivelevel);
    },
    // 机构ID字典翻译
    // orgIdFormat(row, column) {
    //   return this.selectDictLabel(this.orgIdOptions, row.orgId);
    // },
    // 信贷系统ID字典翻译
    managerIdFormat(row, column) {
      return this.selectDictLabel(this.managerIdOptions, row.managerId);
    },
    // 数据日期字典翻译
    sjrqFormat(row, column) {
      return this.selectDictLabel(this.sjrqOptions, row.sjrq);
    },
    // 创建时间字典翻译
    createTimeFormat(row, column) {
      return this.selectDictLabel(this.createTimeOptions, row.createTime);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancelUpData() {
      this.openUpdata = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        village: null,
        hs: null,
        zrs: null,
        ckye: null,
        ckhs: null,
        rjckje: null,
        yxckhs: null,
        dkye: null,
        dkhs: null,
        rjdkje: null,
        sxqyhs: null,
        sxqyl: null,
        yxqyl: null,
        dzyhgs: null,
        rjdzyhgs: null,
        hydzyhgs: null,
        rjhydzyhgs: null,
        productHs: null,
        vaildHs: null,
        productCoverage: null,
        vaildCoverage: null,
        agez: null,
        ageone: null,
        agetwo: null,
        agethree: null,
        agefour: null,
        agefive: null,
        firstlevel: null,
        seclevel: null,
        thrlevel: null,
        fourlevel: null,
        fivelevel: null,
        orgId: null,
        managerId: null,
        sjrq: null,
        createTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      //this.ids = selection.map(item => item.village)
      this.ids = selection.map(item => item.id);
      this.single = selection.length!==1
      this.multiple = !selection.length
      this.sqKhxx = selection;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.sqKhxx = [];
      this.reset();
      this.open = true;
      this.title = "添加包片社区-包片社区报表";

    },
    /** 修改按钮操作 */
    handleUpdate(row) {

      queryCustomerInfo(this.sqKhxx[0].idCard).then(response => {
        if(response.code == '200'){
          this.queryInfo = response.data;
          this.rules = {};
          //console.log(JSON.stringify(this.queryInfo))
          this.upDateId = this.queryInfo.id;
          if(this.queryInfo.dataWgWgsq.length > 0){
            this.dataWgWgsqSqUpdate.labour = this.queryInfo.dataWgWgsq[0].labour;
            this.dataWgWgsqSqUpdate.sssq = this.queryInfo.dataWgWgsq[0].sssq;
            this.dataWgWgsqSqUpdate.sssjsq = this.queryInfo.dataWgWgsq[0].sssjsq;
            this.cqjzvalue = this.queryInfo.dataWgWgsq[0].longLive;
          }
          if(this.queryInfo.dataGtgsh.length > 0){
            this.dataWgWgsqSqUpdate.shmt = this.queryInfo.dataGtgsh[0].shmt;
            this.dataWgWgsqSqUpdate.shzcmc = this.queryInfo.dataGtgsh[0].shzcmc;
            this.dataWgWgsqSqUpdate.fddbr = this.queryInfo.dataGtgsh[0].fddbr;
            this.dataWgWgsqSqUpdate.fddbrzjhm = this.queryInfo.dataGtgsh[0].fddbrzjhm;
            this.dataWgWgsqSqUpdate.sjjyr = this.queryInfo.dataGtgsh[0].sjjyr;
            this.dataWgWgsqSqUpdate.sjjyrzjhm = this.queryInfo.dataGtgsh[0].sjjyrzjhm;
            this.dataWgWgsqSqUpdate.jydz = this.queryInfo.dataGtgsh[0].jydz;
            this.dataWgWgsqSqUpdate.sshy = this.queryInfo.dataGtgsh[0].sshy;
            this.dataWgWgsqSqUpdate.jyzk = this.queryInfo.dataGtgsh[0].jyzk;
          }
          if(this.queryInfo.dataWgWgcj.length > 0){
            this.dataWgWgsqSqUpdate.town = this.queryInfo.dataWgWgcj[0].town;
            this.dataWgWgsqSqUpdate.village = this.queryInfo.dataWgWgcj[0].village;
            this.dataWgWgsqSqUpdate.workAddress = this.queryInfo.dataWgWgcj[0].workAddress;
            this.badHabitsvalue = this.queryInfo.dataWgWgcj[0].badHabits;
            this.xbvalue = this.queryInfo.dataWgWgcj[0].sex;
            this.cjyhzgxvalue = this.queryInfo.dataWgWgcj[0].yhzgx;
            this.healthvalue = this.queryInfo.dataWgWgcj[0].health;
            this.houservalue = this.queryInfo.dataWgWgcj[0].hourse;
            this.carvalue = this.queryInfo.dataWgWgcj[0].car;
          }
          this.dataWgWgsqSqUpdate.name = this.sqKhxx[0].name;
          this.dataWgWgsqSqUpdate.idCard = this.sqKhxx[0].idCard;
          this.dataWgWgsqSqUpdate.hzxm = this.sqKhxx[0].hzxm;
          this.dataWgWgsqSqUpdate.hjbh = this.sqKhxx[0].hjbh;
          this.dataWgWgsqSqUpdate.age = this.queryInfo.age;
          this.dataWgWgsqSqUpdate.phone = this.queryInfo.phone;


          this.dataWgWgsqSqUpdate.address = this.queryInfo.address;
          this.dataWgWgsqSqUpdate.joinAcive = this.sqKhxx[0].joinAcive;


          this.yhzgxvalue = this.sqKhxx[0].yhzgx;
          this.orgvalue = this.queryInfo.orgId;
          this.managervalue = this.queryInfo.userId;
          this.khlxvalue = this.queryInfo.customerType;
          this.dataWgWgsqSqUpdate.remark = this.sqKhxx[0].remark;

            this.openUpdata = true;
            this.title = "修改网格村居-包片居民报表";
            this.ifUpAndAdd = row.isTrusted;
        }else{
          this.msgSuccess(response.msg);
          this.openUpdata = false;
        }
      });


    },
    submitFormUpdate() {
      var group = [];
      for (var i = 0; i < this.qtbqvalue.length; i++) {

            group.push({
                 groupCode: this.qtbqvalue[i].split('|')[1],
                 groupName: this.qtbqvalue[i].split('|')[0]
            })
      }
      var sqData = {
        name: this.dataWgWgsqSqUpdate.name,
        idCard: this.dataWgWgsqSqUpdate.idCard,
        hzxm: this.dataWgWgsqSqUpdate.hzxm,
        hjbh: this.dataWgWgsqSqUpdate.hjbh,
        age: this.dataWgWgsqSqUpdate.age,
        phone: this.dataWgWgsqSqUpdate.phone,
        groupLabel: group,
        customerType: this.khlxvalue,
        id: this.upDateId,
        orgId: this.orgvalue,
        userId: this.managervalue,
        dataGtgsh: [{}],
        dataWgWgsq: [{}],
        dataWgWgcj: [{}]

      }

      if(this.queryInfo.dataWgWgsq.length > 0){
        sqData.dataWgWgsq[0].id = this.queryInfo.dataWgWgsq[0].id;
        sqData.dataWgWgsq[0].yhzgx = this.yhzgxvalue;
        sqData.dataWgWgsq[0].remark = this.dataWgWgsqSqUpdate.remark;
        //sqData.dataWgWgsq[0].managerId = this.managervalue;
        //sqData.dataWgWgsq[0].orgId = this.orgvalue;
        sqData.dataWgWgsq[0].sssq = this.dataWgWgsqSqUpdate.sssq;
        sqData.dataWgWgsq[0].labour = this.dataWgWgsqSqUpdate.labour;
        sqData.dataWgWgsq[0].jzAddress = this.dataWgWgsqSqUpdate.jzAddress;
        sqData.dataWgWgsq[0].joinAcive = this.dataWgWgsqSqUpdate.joinAcive;
        sqData.dataWgWgsq[0].sssjsq = this.dataWgWgsqSqUpdate.sssjsq;
        sqData.dataWgWgsq[0].longLive = this.cqjzvalue;
      }else{
        sqData.dataWgWgsq = [];
      }

      if(this.queryInfo.dataGtgsh.length > 0){
        sqData.dataGtgsh[0].shmt = this.dataWgWgsqSqUpdate.shmt;
        sqData.dataGtgsh[0].shzcmc = this.dataWgWgsqSqUpdate.shzcmc;
        sqData.dataGtgsh[0].fddbr = this.dataWgWgsqSqUpdate.fddbr;
        sqData.dataGtgsh[0].fddbrzjhm = this.dataWgWgsqSqUpdate.fddbrzjhm;
        sqData.dataGtgsh[0].sjjyr = this.dataWgWgsqSqUpdate.sjjyr;
        sqData.dataGtgsh[0].sjjyrzjhm = this.dataWgWgsqSqUpdate.sjjyrzjhm;
        sqData.dataGtgsh[0].jydz = this.dataWgWgsqSqUpdate.jydz;
        sqData.dataGtgsh[0].sshy = this.dataWgWgsqSqUpdate.sshy;
        sqData.dataGtgsh[0].jyzk = this.dataWgWgsqSqUpdate.jyzk;
        sqData.dataGtgsh[0].id = this.queryInfo.dataGtgsh[0].id;
        sqData.dataGtgsh[0].sssq = this.dataWgWgsqSqUpdate.sssq;
        sqData.dataGtgsh[0].sssjsq = this.dataWgWgsqSqUpdate.sssjsq;
      }else{
        sqData.dataGtgsh = [];
      }

      if(this.queryInfo.dataWgWgcj.length > 0){
        sqData.dataWgWgcj[0].id = this.queryInfo.dataWgWgcj[0].id;
        sqData.dataWgWgcj[0].town = this.dataWgWgsqSqUpdate.town;
        sqData.dataWgWgcj[0].village = this.dataWgWgsqSqUpdate.village;
        sqData.dataWgWgcj[0].sex = this.xbvalue;
        sqData.dataWgWgcj[0].yhzgx = this.cjyhzgxvalue;
        sqData.dataWgWgcj[0].health = this.healthvalue;
        sqData.dataWgWgcj[0].car = this.carvalue;
        sqData.dataWgWgcj[0].hourse = this.houservalue;
        sqData.dataWgWgcj[0].badHabits = this.badHabitsvalue;
        sqData.dataWgWgcj[0].address = this.dataWgWgsqSqUpdate.address;
        sqData.dataWgWgcj[0].workAddress = this.dataWgWgsqSqUpdate.workAddress;
      }else{
        sqData.dataWgWgcj = [];
      }



      console.log(sqData)
      updateCustomer(sqData).then(response => {
        this.msgSuccess("修改成功");
        this.openUpdata = false;
        this.getList();
      });
    },
    /** 提交按钮 */
    submitForm() {
      var group = [];
      for (var i = 0; i < this.qtbqvalue.length; i++) {

            group.push({
                 groupCode: this.qtbqvalue[i].split('|')[1],
                 groupName: this.qtbqvalue[i].split('|')[0]
            })
      }
      var sqData = {
        name: this.dataWgWgsqSq.name,
        idCard: this.dataWgWgsqSq.idCard,
        hzxm: this.dataWgWgsqSq.hzxm,
        hjbh: this.dataWgWgsqSq.hjbh,
        age: this.dataWgWgsqSq.age,
        phone: this.dataWgWgsqSq.phone,
        groupLabel: group,
        customerType: this.khlxvalue,
        orgId: this.orgvalue,
        userId: this.managervalue,
        dataGtgsh: [{}],
        dataWgWgsq: [{}],
        dataWgWgcj: [{}]

      }

      if(this.dataWgWgsqSq.town != ""){
        sqData.dataWgWgcj[0].town = this.dataWgWgsqSq.town;
      }else{
        sqData.dataWgWgcj = [];
      }
      if(this.dataWgWgsqSq.village != ""){
        sqData.dataWgWgcj[0].village = this.dataWgWgsqSq.village;
      }else{
        sqData.dataWgWgcj = [];
      }

      if(this.dataWgWgsqSq.sex != ""){
        sqData.dataWgWgcj[0].sex = this.xbvalue;
      }
      if(this.cjyhzgxvalue != ""){
        sqData.dataWgWgcj[0].yhzgx = this.cjyhzgxvalue;
      }
      if(this.healthvalue != ""){
        sqData.dataWgWgcj[0].health = this.healthvalue;
      }
      if(this.houservalue != ""){
        sqData.dataWgWgcj[0].hourse = this.houservalue;
      }
      if(this.carvalue != ""){
        sqData.dataWgWgcj[0].car = this.carvalue;
      }
      if(this.badHabitsvalue != ""){
        sqData.dataWgWgcj[0].badHabits = this.badHabitsvalue;
      }
      if(this.dataWgWgsqSq.address != ""){
        sqData.dataWgWgcj[0].address = this.dataWgWgsqSq.address;
      }
      if(this.dataWgWgsqSq.workAddress != ""){
        sqData.dataWgWgcj[0].workAddress = this.dataWgWgsqSq.workAddress;
      }


      if(this.yhzgxvalue!=""){
        sqData.dataWgWgsq[0].yhzgx = this.yhzgxvalue;
      }
      if(this.dataWgWgsqSq.remark!=""){
        sqData.dataWgWgsq[0].remark = this.dataWgWgsqSq.remark;
      }
      // if(this.managervalue!=""){
      //   sqData.dataWgWgsq[0].managerId = this.managervalue;
      // }
      // if(this.orgvalue!=""){
      //   sqData.dataWgWgsq[0].orgId = this.orgvalue;
      // }
      if(this.dataWgWgsqSq.sssq!=""){
        sqData.dataWgWgsq[0].sssq = this.dataWgWgsqSq.sssq;
      }
      if(this.dataWgWgsqSq.labour!=""){
        sqData.dataWgWgsq[0].labour = this.dataWgWgsqSq.labour;
      }
      if(this.dataWgWgsqSq.jzAddress!=""){
        sqData.dataWgWgsq[0].jzAddress = this.dataWgWgsqSq.jzAddress;
      }
      if(this.dataWgWgsqSq.joinAcive!=""){
        sqData.dataWgWgsq[0].joinAcive = this.dataWgWgsqSq.joinAcive;
      }
      if(this.dataWgWgsqSq.sssjsq!=""){
        sqData.dataWgWgsq[0].sssjsq = this.dataWgWgsqSq.sssjsq;
      }else{
        sqData.dataWgWgsq = []
      }
      if(this.cqjzvalue!=""){
        sqData.dataWgWgsq[0].longLive = this.cqjzvalue;
      }

      if(this.dataWgWgsqSq.shmt!=""){
        sqData.dataGtgsh[0].shmt = this.dataWgWgsqSq.shmt;
        sqData.dataGtgsh[0].sssjsq = this.dataWgWgsqSq.sssjsq;
        sqData.dataGtgsh[0].sssq = this.dataWgWgsqSq.sssq;
      }else{
        sqData.dataGtgsh = [];
      }
      if(this.dataWgWgsqSq.shzcmc!=""){
        sqData.dataGtgsh[0].shzcmc = this.dataWgWgsqSq.shzcmc;
      }
      if(this.dataWgWgsqSq.fddbr!=""){
        sqData.dataGtgsh[0].fddbr = this.dataWgWgsqSq.fddbr;
      }
      if(this.dataWgWgsqSq.fddbrzjhm!=""){
        sqData.dataGtgsh[0].fddbrzjhm = this.dataWgWgsqSq.fddbrzjhm;
      }
      if(this.dataWgWgsqSq.sjjyr!=""){
        sqData.dataGtgsh[0].sjjyr = this.dataWgWgsqSq.sjjyr;
      }
      if(this.dataWgWgsqSq.sjjyrzjhm!=""){
        sqData.dataGtgsh[0].sjjyrzjhm = this.dataWgWgsqSq.sjjyrzjhm;
      }
      if(this.dataWgWgsqSq.jydz!=""){
        sqData.dataGtgsh[0].jydz = this.dataWgWgsqSq.jydz;
      }
      if(this.dataWgWgsqSq.sshy!=""){
        sqData.dataGtgsh[0].sshy = this.dataWgWgsqSq.sshy;
      }
      if(this.dataWgWgsqSq.jyzk!=""){
        sqData.dataGtgsh[0].jyzk = this.dataWgWgsqSq.jyzk;
      }

      console.log(sqData)
      addCustomer(sqData).then(response => {
        this.msgSuccess("新增成功");
        this.open = false;
        this.getList();
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const villages = row.village || this.ids;
      this.$confirm('是否确认删除网格村居-包片居民报表编号为"' + villages + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delBpjm(villages);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('buss/bpjm/export', {
        ...this.queryParams
      }, `buss_bpjm.xlsx`)
    }
  }
};
</script>
